module(
    name = "oci-container",
    version = "0.0.0",
)

# https://github.com/bazelbuild/rules_rust/releases
bazel_dep(name = "rules_rust", version = "0.47.1")

# https://github.com/bazel-contrib/toolchains_llvm
bazel_dep(name = "toolchains_llvm", version = "1.0.0")

# OCI Container rules
# https://github.com/bazel-contrib/rules_oci/releases
bazel_dep(name = "rules_oci", version = "1.7.6")

# https://github.com/bazelbuild/rules_pkg/releases
bazel_dep(name = "rules_pkg", version = "0.10.1")

llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")

LLVM_VERSIONS = {
    "": "16.0.0",
}

# Host LLVM toolchain.
llvm.toolchain(
    name = "llvm_toolchain",
    llvm_versions = LLVM_VERSIONS,
)
use_repo(llvm, "llvm_toolchain", "llvm_toolchain_llvm")

register_toolchains("@llvm_toolchain//:all")

# Rust toolchain
RUST_EDITION = "2021"

RUST_VERSION = "1.79.0"

rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(
    edition = RUST_EDITION,
    versions = [RUST_VERSION],
)
use_repo(rust, "rust_toolchains")

register_toolchains("@rust_toolchains//:all")

oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")

#
# https://github.com/GoogleContainerTools/distroless
oci.pull(
    name = "distroless",
    digest = "sha256:e1065a1d58800a7294f74e67c32ec4146d09d6cbe471c1fa7ed456b2d2bf06e0",
    image = "gcr.io/distroless/cc-debian12",
    platforms = [
        "linux/amd64",
        "linux/arm64/v8",
    ],
)
use_repo(oci, "distroless")

crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate")

#
# External crates
crate.spec(
    package = "arc-swap",
    version = "1.7",
)
crate.spec(
    features = ["derive"],
    package = "serde",
    version = "1.0",
)
crate.spec(
    package = "serde_json",
    version = "1.0",
)
crate.spec(
    default_features = False,
    features = [
        "macros",
        "net",
        "rt-multi-thread",
        "signal",
    ],
    package = "tokio",
    version = "1.38",
)
crate.spec(
    features = ["signal"],
    package = "tokio-cron-scheduler",
    version = "0.10",
)
crate.spec(
    package = "warp",
    version = "0.3",
)
crate.from_specs()
use_repo(crate, "crates")
